<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/10/20
 * Time: 14:29
 */

namespace app\adminapiv3\validate;


use think\Validate;

class ServiceValidate extends Validate
{
    //验证规则
    protected $rule = [
        'id' => 'require|integer',
        'service_id' => 'require',
        'name|服务商名称' => 'require|max:50',
        'is_local|是否为本地服务商' => 'require|in:0,1',
        'contact|联系人' => 'require|max:50',
        'phone|联系电话' => 'require|max:20',
        'description|服务商说明' => 'max:366',
        'status|服务商状态' => 'require|in:1,2,3',
        'end_reason|终止原因' => 'require|in:1,2,3,4',
        'end_reason_description|其他原因' => 'max:85',
        'start_time|首次签约时间' => 'require',
        'end_time|终止时间' => 'require',
        'type|服务商类别' => 'require|array',
        'content|服务描述' => 'max:85',
        'position|职位' => 'max:85',
        'address|服务商地址' => 'max:85'
    ];

    //错误信息
    protected $message = [
        'is_local.require' => '请选择是否为本地服务商',
        'is_local.in' => '本地服务商请选择\'是\'或者\'否\'',
        'type.array' => '服务商类别参数格式错误',
        'end_reason.in' => '终止原因参数格式错误'
    ];

    //验证场景
    protected $scene = [
        //添加
        'add' => ['name','contact','position','phone','start_time','is_local','address','content','description','type'],
        //修改
        'modify' => ['id','name','contact','position','phone','start_time','is_local','address','content','description','type'],
        //删除
        'del' => ['service_id'],
        //服务历史
        'service_history' => ['service_id'],
        //详情
        'detail' => ['id'],
        //终止合作
        'endContract' => ['service_id','end_reason','end_reason_description'],
        //续约更新
        'updateService' => ['service_id','end_time','content'],
    ];


}